package health.lm.com.mine.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import health.lm.com.mine.R;
import health.lm.com.mine.entity.IntegralDetailListEntity;

/**
 *  积分明细
 * @author GQI
 */
public class IntegralDetailListAdapter extends BaseQuickAdapter<IntegralDetailListEntity.Credit_log,BaseViewHolder> {

    public IntegralDetailListAdapter(@Nullable List<IntegralDetailListEntity.Credit_log> data) {
        super(R.layout.item_jf_detail, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, IntegralDetailListEntity.Credit_log item) {
        helper.setText(R.id.tv_title,item.getType())
                .setText(R.id.tv_content,getDate2String(item.getCreate_time(),"yyyy-MM-dd HH:mm:ss"))
                .setText(R.id.tv_todo,String.format("+%s分",item.getCredit()));
    }
    /**
     *
     * @param time  1541569323155
     * @param pattern yyyy-MM-dd HH:mm:ss
     * @return 2018-11-07 13:42:03
     */
    public static String getDate2String(long time, String pattern) {
        Date date = new Date(time*1000L);
        SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.getDefault());
        return format.format(date);
    }
}
